/**
 * 
 */
package edu.fiu.cs.kdrg.sql.syntax.tree;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Chunqiu Zeng
 * 
 */

public class Node {

	/**
	 * name of node
	 */
	private String name = "";

	/**
	 * type of node
	 */
	private NodeType type = NodeType.SELECT_STATEMENT;

	/**
	 * its children
	 */
	private List<Node> children = new ArrayList<Node>();

	/**
	 * Constructor
	 */
	public Node() {
	}

	/**
	 * @param name
	 */
	public Node(String name) {
		this.name = name;
	}

	/**
	 * @param name
	 * @param type
	 */
	public Node(String name, NodeType type) {
		this.name = name;
		this.type = type;
	}

	/**
	 * @return the type
	 */
	public NodeType getType() {
		return type;
	}

	/**
	 * @param type
	 *            the type to set
	 */
	public void setType(NodeType type) {
		this.type = type;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @param node
	 */
	public void addChild(Node node) {
		if (node != null)
			children.add(node);
	}

	/**
	 * @param index
	 * @return
	 */
	public Node getChild(int index) {
		return children.get(index);
	}

	/**
	 * @return
	 */
	public int childrenCount() {
		return children.size();
	}

}
